using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ServiceProcess;
using Microsoft.Win32;
using System.Configuration.Install;

namespace eTMS.WindowServices
{
    [RunInstaller(true)]
    public partial class WRLCInstaller : Installer
    {
        public WRLCInstaller()
        {
            ServiceProcessInstaller serviceProcessInstaller =
                                new ServiceProcessInstaller();
            ServiceInstaller serviceInstaller = new ServiceInstaller();

            //# Service Account Information
            serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
            serviceProcessInstaller.Username = null;
            serviceProcessInstaller.Password = null;
            //# Service Information
            serviceInstaller.DisplayName = "eTMS Server Services";
            serviceInstaller.StartType = ServiceStartMode.Automatic;

            //# This must be identical to the WindowsService.ServiceBase name
            //# set in the constructor of WindowsService.cs
            serviceInstaller.ServiceName = "eTMSService";

            this.Installers.Add(serviceProcessInstaller);
            this.Installers.Add(serviceInstaller);
            RegistryKey ckey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\eTMS", true);
            // Good to always do error checking!

            if (ckey != null)
            {
                // Ok now lets make sure the "Type" value is there, 

                //and then do our bitwise operation on it.

                if (ckey.GetValue("Type") != null)
                {
                    ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256));
                }
            }
        }
    }
}